<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="username current"></div>
    <div id="myDiv">
        <div class="selected"></div>
        <div class="selected"></div>
        <div class="selected"></div>
    </div>
    <script>
        // 取得所有类名中包含"username"和"current"元素
        let allUsernameCurrent = document.getElementsByClassName("username current")
        console.log(allUsernameCurrent)  // HTMLCurrent[1]

        // 取得id为myDiv的子元素树中所有包含selected类的元素
        let selected = document.getElementById("myDiv").getElementsByClassName("selected")
        console.log(selected) // HTMLCollection(3) [div.selected, div.selected, div.selected]
    </script>
</body>
</html>